package 暑假实习面试;

import java.util.Scanner;
import java.util.Stack;

public class No1My任意进制转换 {

    /**
     * 原进制,当前进制,目标进制
     */
    public String baseConversion(String source,Integer sourceSystem,Integer targetSystem) {

        /**
         * 反手转成十进制
         */
        long tenSystemNum=convertTenSystem(source,sourceSystem);

        /**
         * 再将十进制转为目标进制返回
         */
        return convertYourSystem(tenSystemNum,targetSystem);
    }

    /**
     * 转十进制方法
     */
    public long convertTenSystem(String source,Integer sourceSystem) {

        if(sourceSystem.equals(10)){
            return Long.parseLong(source);
        }

        char[] chars = source.toCharArray();
        int[] nums=new int[chars.length];

        for (int i = 0; i < chars.length; i++) {
            nums[i]=chars[i]-'0';
        }

        int sum=0;

        //然后开始累乘
        for (int i = nums.length-1; i >= 0; i--) {

            sum+=nums[i]*Math.pow(Double.valueOf(String.valueOf(sourceSystem)),(double)(nums.length-1-i));

        }

        return sum;
    }

    /**
     * 十进制转目标进制方法
     */
    public String convertYourSystem(long source, Integer targetSystem) {

        StringBuilder sb=new StringBuilder();

        while (source!=0){
            sb.append(source%targetSystem);
            source/=targetSystem;
        }

        return sb.reverse().toString();
    }

    public static void main(String[] args) {

//        No1My任意进制转换 n=new No1My任意进制转换();
//        String result = n.baseConversion("54", 7, 10);
//        System.out.println(result);

        Scanner input=new Scanner(System.in);

        while (input.hasNext()){

            int length=input.nextInt();

            Stack<Integer> stack=new Stack<>();

            for (int i = 0; i < length; i++) {
                int num=input.nextInt();
                //利用栈来实现
                if(!stack.isEmpty()&&(num-stack.peek()==0||stack.peek()-num==0)){
                    stack.pop();//取出后,也不放入
                }else{
                    stack.add(num);
                }
            }

            if(stack.isEmpty()){
                System.out.println("RedHat V5");
            }else{
                int sum=0;
                for (Integer num : stack) {
                    sum+=num;
                }
                System.out.println(sum);
            }
        }

    }



}
